#include <string>
#include <list>
#include <iostream>

using namespace std;

void permutation(string word, string prevStr){
	if(word == "") {
		cout << prevStr << endl;
		return;
	}

	string tmp;
	for(int i = 0; i < word.length(); i++){
		tmp = word;
		tmp = tmp.erase(i,1);
		permutation(tmp, prevStr + word[i]);
	}
}

int main(){
	string p = "abcdef";
	permutation(p, "");

	return 0;
}
